<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=device-width">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<meta name="format-detection" content="telephone=no">
	<meta content="telephone=no" name="format-detection">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<link href="/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" media="screen and (max-width:900px)" href="/assets/stylesheets/style_wap.css" type="text/css" />
	<link rel="stylesheet" media="screen and (min-width:900px)" href="/assets/stylesheets/style_pc.css" type="text/css" />
	<title>选择支付方式</title>
</head>
<body>
	<!-- 前端嵌套写法，仅供前端使用，首页有完整代码 -->
	<div class="topline" id="J_topline" data-til="选择支付方式">
		<nav th:replace="hjh/include::menuV"></nav>
	</div>

	<div class="order_st ppay content">
		<div class="odtil">选择支付方式<p class="pp_mon">应付金额：<span class="pp_num" th:text="${'￥'+ #numbers.formatDecimal(order.amount * 0.01, 1, 2)}">1888.00元</span></p></div>
		<div class="pp_list">
			<a href="javascript:;" data-type="zgyl" data-text="中国银联" class="pp_lse"><img src="/assets/images/icon_pay04.png"></a>
			<a th:href="@{'/alipay_pay?id='+${order.id}}" data-type="zfb" data-text="支付宝" class="pp_lse"><img src="/assets/images/icon_pay03.png"></a>
			<a th:href="@{'/wx_pay?id='+${order.id}}" data-type="wx" data-text="微信" class="pp_lse"><img src="/assets/images/icon_pay01.png"></a>
			<a id="cash_pay_img_id" href="javascript:;" class="J_prlsst prlsst" data-toggle="modal" data-target="#myModal" data-type="jf" data-text="现金积分"
				class="pp_lse" th:onclick="${'cash_pay('+order.amount+','+cashPointBalance+')'}"><img
					src="/assets/images/icon_pay02.png"></a>
		</div>

		<!-- 模态框（Modal） -->
		<div class="modal fade" id="myModal" data-keyboard="true" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
			 aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
						<h4 class="modal-title" id="myModalLabel">现金积分支付</h4>
					</div>
					<div class="modal-body form-horizontal formline">
						<div class="form-group" hidden="hidden">
							<label class="col-sm-4 control-label" for="model_id">编号</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="model_id"
									   placeholder="编号" th:value="${order.id}">
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-4 control-label" for="model_orderNo_id">订单编号</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="model_orderNo_id"
									   th:value="${order.orderNo}" disabled="disabled">
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-4 control-label" for="cash_balance_str_id">现金积分余额</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="cash_balance_str_id"
									   th:value="${cashPointBalanceStr}" disabled="disabled">
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-4 control-label" for="pay_pwd_id">交易密码</label>
							<div class="col-sm-8">
								<input type="password" class="form-control" id="pay_pwd_id" placeholder="请输入交易密码">
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<div class="form-group">
							<label class="col-sm-4 control-label" for="model_pay_btn_id"></label>
							<div class="col-sm-4">
								<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
							</div>
							<div class="col-sm-4">
								<button type="button" class="btn btn-primary" id="model_pay_btn_id">支付</button>
							</div>
						</div>
					</div>
				</div><!-- /.modal-content -->
			</div><!-- /.modal-dialog -->
		</div>
	</div>

	<nav th:replace="hjh/include::bottomV"></nav>
	<script language="javascript" type="text/javascript" src="/assets/javascript/jquery-2.1.4.min.js"></script>
	<script language="javascript" src="/js/bootstrap.min.js?v=3.3.6"></script>
	<script language="javascript" type="text/javascript" src="/assets/javascript/func.js"></script>
	<script language="JavaScript">
		$(function () {
			$("#model_pay_btn_id").click(function () {
                var payPwd = $("#pay_pwd_id").val();
                var orderId = $("#model_id").val();
                if(!payPwd){
                    alert('支付密码不能为空！');
                    return;
                }
                var data = {"orderId":orderId,"payPwd":payPwd};
                $.ajax({
                    type: "POST",
                    url: "/cash_pay",
                    data: JSON.stringify(data),
                    dataType: "json",
                    contentType:"application/json;charset=utf8",
                    success: function(res){
                        if(res.code==0){
                            // 提交成功
                            alert('提交成功');
                            $("#myModal").modal('hide');
                            window.location.href="/cash_points_list";
                        }else{
                            alert('提交失败，'+res.msg)
                        };
                    },
                    complete:function(){
                        isajax = false;
                    }
                });

            })
        })

		function cash_pay(price,cash) {
			if(price>cash){
			    alert("现金积分余额不足");
				return;
			}
			$("#pay_pwd_id").val("");
            $("#myModal").show();
        }
	</script>
</body>
</html>
